package com.lbb.utils.recycler

import android.view.ViewGroup
import androidx.viewbinding.ViewBinding

abstract class BaseModelAdapter<T, B : ViewBinding> : BaseStateAdapter<BaseHolder<B>>() {

    var list: List<T> = mutableListOf()
        set(value) {
            if (value.isNullOrEmpty()) {
                state = TYPE_EMPTY
            } else {
                field = value
                state = TYPE_CONTENT
            }
        }

    protected abstract fun getBinDing(parent: ViewGroup): B

    override fun getItemSize(): Int {
        return list.size
    }

    override fun onCreateHolder(parent: ViewGroup, viewType: Int): BaseHolder<B> {
        return BaseHolder(getBinDing(parent))
    }



}